package com.zhongkai.service.impl;

import com.mysql.jdbc.StringUtils;
import com.zhongkai.Bean.PageBean;
import com.zhongkai.Bean.Pillar;
import com.zhongkai.app.service.IBaseDao;
import com.zhongkai.app.service.PageQuerDao;
import com.zhongkai.app.service.WarehouseService;
import com.zhongkai.model.utils.ZhongkaiResult;
import com.zhongkai.model3.*;
import org.hibernate.criterion.DetachedCriteria;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class WarehouseServiceImpl implements WarehouseService {

    @Autowired
    private IBaseDao iBaseDao;

    @Autowired
    private PageQuerDao pageQuerDao;


    /**
     * 工程库存添加
     *
     * @param uuid      操作用户uuid
     * @param user_name 操做用户姓名
     * @param war_name  库存物料名称
     * @param war_count 数量
     * @param war_uuid  产品uuid
     */
    @Override
    public ZhongkaiResult addWarehouse(String uuid, String user_name, String war_name, Integer war_count, String war_uuid) {
        if (StringUtils.isNullOrEmpty(war_name) || StringUtils.isNullOrEmpty(war_uuid)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse warehouse;
        Warehouse2 warehouse2;
        Warehouse3 warehouse3;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warName='" + war_name + "'");
        warehouse2 = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warName='" + war_name + "'");
        warehouse3 = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warName='" + war_name + "'");

        if (warehouse != null) {

            return ZhongkaiResult.build(400, "已在工程库存中存在");

        } else if (warehouse2 != null) {
            return ZhongkaiResult.build(400, "已在办公库存中存在");
        } else if (warehouse3 != null) {

            return ZhongkaiResult.build(400, "已在产品库存中存在");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳

        warehouse = new Warehouse();

        warehouse.setWarCount(war_count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);
//.................................................................................................
        Record record = new Record();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        try {
            iBaseDao.save(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "保存失败");
        }
    }


    /**
     * 工程库存增加
     *
     * @param uuid      操作用户uuid
     * @param user_name 操做用户姓名
     * @param war_name  库存物料名称
     * @param war_count 数量
     * @param war_uuid  产品uuid
     * @param war_ps    备注
     */
    @Override
    public ZhongkaiResult putWarehouse(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {

        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse warehouse;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        warehouse.setWarCount(warehouse.getWarCount() + war_count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);
//.................................................................................................
        Record record = new Record();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }


    /**
     * 工程库存减少
     *
     * @param uuid      操作用户uuid
     * @param user_name 操做用户姓名
     * @param war_name  库存物料名称
     * @param war_count 数量
     * @param war_uuid  产品uuid
     * @param war_ps    备注
     */
    @Override
    public ZhongkaiResult outWarehouse(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse warehouse;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }
        int count = warehouse.getWarCount() - war_count;

        if (count < 0) {
            return ZhongkaiResult.build(400, "库存不足");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳


        warehouse.setWarCount(count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);

//.................................................................................................
        Record record = new Record();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("2");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }

    /**
     * 删除库存
     *
     * @param uuid      操作用户uuid
     * @param user_name 操做用户姓名
     * @param war_name  库存物料名称
     * @param war_uuid  产品uuid
     */
    @Override
    public ZhongkaiResult removeWarehouse(String uuid, String user_name, String war_name, String war_uuid) {

        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        Warehouse warehouse;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        Record record = new Record();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(warehouse.getWarCount()));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("3");//1入库 2出库 3删除

        record.setIndUuid("0101");

        try {
            iBaseDao.delete(warehouse); //库存表
            iBaseDao.save(record); //出库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "删除失败");
        }
    }


    //库存列表
    @Override
    public ZhongkaiResult listWarehouse(Integer page, Integer rows) {
        if (page == 0 || rows == 0) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        try {
            PageBean pageBean = new PageBean();
            pageBean.setCurrentPage(page);
            pageBean.setPageSize(rows);
            DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Warehouse.class);
            //   detachedCriteria.addOrder(Order.desc("warTime")); //根据传入的字段进行降序排序
            pageBean.setDetachedCriteria(detachedCriteria);
            pageQuerDao.pageQuery(pageBean);
            return ZhongkaiResult.ok(pageBean);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(405, "查询失败");
        }
    }


    //................................................办公库存..........................................................

    @Override
    public ZhongkaiResult addWarehouse2(String uuid, String user_name, String war_name, Integer war_count, String war_uuid) {
        if (StringUtils.isNullOrEmpty(war_name) || StringUtils.isNullOrEmpty(war_uuid)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse warehouse;
        Warehouse2 warehouse2;
        Warehouse3 warehouse3;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warName='" + war_name + "'");
        warehouse2 = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warName='" + war_name + "'");
        warehouse3 = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warName='" + war_name + "'");

        if (warehouse != null) {

            return ZhongkaiResult.build(400, "已在工程库存中存在");

        } else if (warehouse2 != null) {
            return ZhongkaiResult.build(400, "已在办公库存中存在");
        } else if (warehouse3 != null) {

            return ZhongkaiResult.build(400, "已在产品库存中存在");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳

        warehouse2 = new Warehouse2();

        warehouse2.setWarCount(war_count);
        warehouse2.setWarUuid(war_uuid);
        warehouse2.setWarName(war_name);
//.................................................................................................
        Record2 record = new Record2();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        try {
            iBaseDao.save(warehouse2); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "保存失败");
        }
    }

    @Override
    public ZhongkaiResult putWarehouse2(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse2 warehouse;

        warehouse = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        warehouse.setWarCount(warehouse.getWarCount() + war_count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);
//.................................................................................................
        Record2 record = new Record2();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }

    @Override
    public ZhongkaiResult outWarehouse2(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse2 warehouse;

        warehouse = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }
        int count = warehouse.getWarCount() - war_count;

        if (count < 0) {
            return ZhongkaiResult.build(400, "库存不足");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳


        warehouse.setWarCount(count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);

//.................................................................................................
        Record2 record = new Record2();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("2");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }

    @Override
    public ZhongkaiResult removeWarehouse2(String uuid, String user_name, String war_name, String war_uuid) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        Warehouse2 warehouse;

        warehouse = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        Record2 record = new Record2();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(warehouse.getWarCount()));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("3");//1入库 2出库 3删除

        record.setIndUuid("0101");

        try {
            iBaseDao.delete(warehouse); //库存表
            iBaseDao.save(record); //出库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "删除失败");
        }
    }

    @Override
    public ZhongkaiResult listWarehouse2(Integer page, Integer rows) {
        if (page == 0 || rows == 0) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        try {
            PageBean pageBean = new PageBean();
            pageBean.setCurrentPage(page);
            pageBean.setPageSize(rows);
            DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Warehouse2.class);
            //   detachedCriteria.addOrder(Order.desc("warTime")); //根据传入的字段进行降序排序
            pageBean.setDetachedCriteria(detachedCriteria);
            pageQuerDao.pageQuery(pageBean);
            return ZhongkaiResult.ok(pageBean);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(405, "查询失败");
        }
    }


    //................................................产品库存..........................................................
    @Override
    public ZhongkaiResult addWarehouse3(String uuid, String user_name, String war_name, Integer war_count, String war_uuid) {
        if (StringUtils.isNullOrEmpty(war_name) || StringUtils.isNullOrEmpty(war_uuid)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse warehouse;
        Warehouse2 warehouse2;
        Warehouse3 warehouse3;

        warehouse = (Warehouse) iBaseDao.get("from Warehouse war where war.warName='" + war_name + "'");
        warehouse2 = (Warehouse2) iBaseDao.get("from Warehouse2 war where war.warName='" + war_name + "'");
        warehouse3 = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warName='" + war_name + "'");

        if (warehouse != null) {

            return ZhongkaiResult.build(400, "已在工程库存中存在");

        } else if (warehouse2 != null) {
            return ZhongkaiResult.build(400, "已在办公库存中存在");
        } else if (warehouse3 != null) {

            return ZhongkaiResult.build(400, "已在产品库存中存在");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳

        warehouse3 = new Warehouse3();

        warehouse3.setWarCount(war_count);
        warehouse3.setWarUuid(war_uuid);
        warehouse3.setWarName(war_name);
//.................................................................................................
        Record2 record = new Record2();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        try {
            iBaseDao.save(warehouse3); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "保存失败");
        }
    }

    @Override
    public ZhongkaiResult putWarehouse3(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse3 warehouse;

        warehouse = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        warehouse.setWarCount(warehouse.getWarCount() + war_count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);
//.................................................................................................
        Record3 record = new Record3();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("1");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }

    @Override
    public ZhongkaiResult outWarehouse3(String uuid, String user_name, String war_name, Integer war_count, String war_uuid, String war_ps) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_ps) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        if (war_count < 0) {
            return ZhongkaiResult.build(400, "请输入正整数");
        }

        Warehouse3 warehouse;

        warehouse = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warUuid='" + war_uuid + "'");

        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }
        int count = warehouse.getWarCount() - war_count;

        if (count < 0) {
            return ZhongkaiResult.build(400, "库存不足");
        }
        long millis = new DateTime().getMillis(); //获取当前系统时间戳


        warehouse.setWarCount(count);
        warehouse.setWarUuid(war_uuid);
        warehouse.setWarName(war_name);

//.................................................................................................
        Record3 record = new Record3();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(war_count));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        record.setRecordTime(millis);
        record.setRecordType("2");//1入库 2出库

        record.setIndUuid("0101");

        record.setWarPs(war_ps); //备注
        try {
            iBaseDao.update(warehouse); //库存工程表
            iBaseDao.save(record);//出入库记录单
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "添加失败");
        }
    }

    @Override
    public ZhongkaiResult removeWarehouse3(String uuid, String user_name, String war_name, String war_uuid) {
        if (StringUtils.isNullOrEmpty(war_uuid) || StringUtils.isNullOrEmpty(war_name)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        Warehouse3 warehouse;

        warehouse = (Warehouse3) iBaseDao.get("from Warehouse3 war where war.warUuid='" + war_uuid + "'");

        SetProduct setProduct = (SetProduct) iBaseDao.get("from SetProduct st where st.setUuid='" + war_uuid + "'");
        if (warehouse == null) {
            return ZhongkaiResult.build(400, "此库存不存在");
        }

        Record3 record = new Record3();

        record.setWarUuid(war_uuid);
        record.setWarName(war_name);
        record.setWarCount(String.valueOf(warehouse.getWarCount()));
        record.setRecordUser(user_name);
        record.setUserId(uuid);

        long millis = new DateTime().getMillis(); //获取当前系统时间戳
        record.setRecordTime(millis);
        record.setRecordType("3");//1入库 2出库 3删除

        record.setIndUuid("0101"); //订单编号


        try {
            iBaseDao.delete(warehouse); //库存表
            iBaseDao.save(record); //出库记录单
            if (setProduct != null){
                iBaseDao.delete(setProduct); //产品表
            }
            return ZhongkaiResult.ok();
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(400, "删除失败");
        }
    }

    @Override
    public ZhongkaiResult listWarehouse3(Integer page, Integer rows) {
        if (page == 0 || rows == 0) {
            return ZhongkaiResult.build(400, "数据不完整");
        }


        try {
            PageBean pageBean = new PageBean();
            pageBean.setCurrentPage(page);
            pageBean.setPageSize(rows);
            DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Warehouse3.class);
            //   detachedCriteria.addOrder(Order.desc("warTime")); //根据传入的字段进行降序排序
            pageBean.setDetachedCriteria(detachedCriteria);
            pageQuerDao.pageQuery(pageBean);
            return ZhongkaiResult.ok(pageBean);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(405, "查询失败");
        }
    }


    /**
     * 库存柱状图 / 饼状图 数据一样的.........
     *
     * @param status 类型 //1工程 2办公 3公司产品
     */

    @Override
    public ZhongkaiResult analyze(String status) {

        if (StringUtils.isNullOrEmpty(status)) {
            return ZhongkaiResult.build(400, "数据不完整");
        }

        List<Object[]> list1;
        switch (status) {
            case "1":
                list1 = iBaseDao.find("select warName,warCount from Warehouse");
                break;
            case "2":
                list1 = iBaseDao.find("select warName,warCount from Warehouse2");
                break;
            case "3":
                list1 = iBaseDao.find("select warName,warCount from Warehouse3");
                break;

            default:
                return ZhongkaiResult.build(400, "参数不合法");
        }

        List<Pillar> pillarBeans = new ArrayList<>();
        for (Object[] objects : list1) {
            Pillar pillarBean = new Pillar();
            pillarBean.setName(objects[0].toString());
            pillarBean.setValue(objects[1].toString());

            pillarBeans.add(pillarBean);

            pillarBean = null;
        }



        return ZhongkaiResult.ok(pillarBeans);

    }


    /**
     * 库存病状图
     *
     * @param status 类型 //1工程 2办公 3公司产品
     */
    @Override
    public ZhongkaiResult cake(String status) {
        return null;
    }
}
